<template>
    <div ref="wrapper">
        <div class="center">
            <slot></slot>
        </div>
    </div>
</template>

<script>
import BetterScroll from 'better-scroll'
export default {
    data(){
        return {
            BScroll:null
        }
    // },
    // methods:{
    //      updated () {
    //     //重新计算高度
    //         this.BScroll.refresh();
    //     //当数据加载完毕以后通知better-scroll
    //     // this.scroll.finishPullUp();
    // }

    },
    
  methods:{
    scrollTo(x,y,time=1000){
      this.BScroll.scrollTo(x,y,time);
    }
  },
    mounted(){
   
            this.BScroll = new BetterScroll(this.$refs.wrapper,{
                click:true,
                probeType:3,
                pullUpLoad:true,
                disableTouch: false,
                disableMouse: false
             })
        
        // this.updated()
        this.BScroll.on('scroll',(position)=>{
            // console.log(position)
           this.$emit('BScroll',position);
        })
        this.BScroll.on('pullingUp',()=>{
            this.BScroll.refresh();
            this.$emit('pageadd')
             
            this.BScroll.finishPullUp();
           
        })
    }
           
        
    
}
</script>

<style scoped>
   
</style>